<template>
<view>
	<view class="wrap">
		<u-back-top :scroll-top="scrollTop"></u-back-top>
	</view>
	<u-loading-icon text="加载中..." textSize="18" :show="jiazai" ></u-loading-icon>
	<u-navbar :bgColor="bgColor" :placeholder="true">
		<view
			class="u-nav-slot d-buhuanhang"
			slot="left"
		>
			<u-icon
				name="arrow-left"
				size="22"
				@click="fanhui()"
			></u-icon>
			<view class="d-buhuanhang d-zuo-10 animated fadeInDown" v-if="scrollTop > 100">
				<view class="d-gaokuang-40 d-kuanggao-20 d-yuanjiao-40 d-box">
					<image v-if="touxiang.touxiang" :src="touxiang.touxiang" mode="aspectFill" class="d-img-26 d-yuanjiao-50 d-beijing-hui"></image>
					<image v-else src="/static/assets/images/avatar.png" mode="aspectFill" class="d-img-26 d-yuanjiao-50 d-beijing-hui"></image>
				</view>
				<view class="d-zuo-10">
					<view class="d-wenzi-14 d-jiacu">{{touxiang.mingcheng}}</view>
				</view>
				<view class="d-kuan-80 d-zuo-10 d-neirong-you" :id="'guanzhu'+touxiang.uid">
					<view v-if="guanzhuuid == 1" @click="getGuanzhus(1,touxiang.uid)" class="d-kuan-50 d-beijing-hei d-wenzi-yanse-bai-0 d-neikuang-zuoyou-2-shangxia-4 d-wenzi-12 d-yuanjiao-50 d-neirong-juzhong" >已关注</view>
					<view v-else @click="getGuanzhus(1,touxiang.uid)" class="d-kuan-50 d-beijing-hui-f6 d-neikuang-zuoyou-2-shangxia-4 d-wenzi-12 d-yuanjiao-50 d-neirong-juzhong" >关 注</view>
				</view>
			</view>
			
		</view>
	</u-navbar>
	<!-- 帖子 -->
<view v-if="tiezijiazai" class="d-kuan">
	

	<!-- 头像 -->
	<view class="d-waikuang-10 d-buhuanhang">
		<!--头像-->
		<view class="d-gaokuang-40 d-kuanggao-40 d-yuanjiao-40 d-box"  @click="getgeren(touxiang.uid)">
			<image v-if="touxiang.touxiang" :src="touxiang.touxiang" mode="aspectFill" class="d-img-40 d-yuanjiao-50 d-beijing-hui"></image>
			<image v-else src="/static/assets/images/avatar.png" mode="aspectFill" class="d-img-40 d-yuanjiao-50 d-beijing-hui"></image>
			<image v-if="rzs == 1" :src="v" mode="aspectFill" class="d-img-10 d-yuanjiao-50  d-box-xia"></image>
		</view>
		<view class="d-kuan d-zuo-10" @click="getgeren(touxiang.uid)">
			<view class="d-wenzi-14 d-jiacu">{{touxiang.mingcheng}}</view>
			<view class="d-wenzi-14 d-wenzi-yanse-hui">{{touxiang[0] && touxiang[0].yonghuzu}}. {{touxiang.guishudi}}</view>
		</view>
		<view class="d-kuan-80 d-neirong-you" :id="'guanzhu'+touxiang.uid">
			<view v-if="guanzhuuid == 1" @click="getGuanzhus(1,touxiang.uid)" class="d-kuan-50 d-beijing-hei d-wenzi-yanse-bai-0 d-neikuang-zuoyou-2-shangxia-4 d-wenzi-12 d-yuanjiao-50 d-neirong-juzhong" >已关注</view>
			<view v-else @click="getGuanzhus(1,touxiang.uid)" class="d-kuan-50 d-beijing-hui-f6 d-wenzi-hei d-wenzi-hei d-neikuang-zuoyou-2-shangxia-4 d-wenzi-12 d-yuanjiao-50 d-neirong-juzhong" >关 注</view>
		</view>
	</view>
	
	<!-- 内容 -->
	<view class="d-waikuang-10" v-if="unshenhe == 0">
		<u-alert :title="title" type = "warning" :show-icon="true" description = "帖子审核中..."></u-alert>
	</view>

	<view >
		<view v-if="tiezineirong.daanshenhe != 1">
			<view class="d-kuan d-zyouyou-juzhong d-shang-10">
				<view class="d-bian-1 d-yuanjiao-50 d-neikuang-5 d-buhuanhang" @click="qurrenshenhe()">
					<view class="d-zuo-10 d-you-10 d-wenzi-12">待审核...</view>
				</view>
			</view>
		</view>
		<view v-if="tiezineirong.daanshenhe == 1" class="d-waikuang-10">
			<view v-if="zhuangtai.wendadaan && zhuangtai.wendadaan.shifouzhongbiaouid !=1">
				<view v-if=" uid == zhuangtai.uid || member['is_admin']" class="d-kuan d-shang-10">
					<u-row customStyle="margin-bottom: 10px" gutter="10">
						<u-col span="3">
							<view class="d-neirong-juzhong d-bian-1 d-yuanjiao-10 d-neikuang-5 d-wenzi-12 d-wenzi-yanse-hongse" @click="getWendajianglidata(1,zhuangtai.tid,zhuangtai.uid)">
								鼓励积分
							</view>
						</u-col>
						<u-col span="3">
							<view class="d-neirong-juzhong d-bian-1 d-yuanjiao-10 d-neikuang-5 d-wenzi-12 d-wenzi-yanse-hongse" @click="getWendajianglidata(2,zhuangtai.tid,zhuangtai.uid)">
								鼓励0.1
							</view>
						</u-col>
						<u-col span="3">
							<view class="d-neirong-juzhong d-bian-1 d-yuanjiao-10 d-neikuang-5 d-wenzi-12 d-wenzi-yanse-hongse"  @click="getWendajianglidata(3,zhuangtai.tid,zhuangtai.uid)">
								感谢参与
							</view>
						</u-col>
						<u-col span="3">
							<view class="d-neirong-juzhong d-bian-1 d-yuanjiao-10 d-neikuang-5 d-wenzi-12 d-wenzi-yanse-hongse"  @click="getWendajianglidata(4,zhuangtai.tid,zhuangtai.uid)">
								选择中标
							</view>
						</u-col>
					</u-row>
				</view>
				
			</view>
			<view v-else>
				<view v-if="zhuangtai.wendadaan && zhuangtai.wendadaan.leixing ==1" class="d-kuan d-zyouyou-juzhong d-shang-10">
					<view class="d-bian-1 d-yuanjiao-50 d-neikuang-5 d-buhuanhang">
						<view class="d-zuo-10 d-you-10 d-wenzi-12">鼓励 1 积分</view>
					</view>
				</view>
				<view v-else-if="zhuangtai.wendadaan && zhuangtai.wendadaan.leixing ==2" class="d-kuan d-zyouyou-juzhong d-shang-10">
					<view class="d-bian-1 d-yuanjiao-50 d-neikuang-5 d-buhuanhang">
						<view class="d-zuo-10 d-you-10 d-wenzi-12">鼓励 0.1 元</view>
					</view>
				</view>
				<view v-else-if="zhuangtai.wendadaan && zhuangtai.wendadaan.leixing ==3" class="d-kuan d-zyouyou-juzhong d-shang-10">
					<view class="d-bian-1 d-yuanjiao-50 d-neikuang-5 d-buhuanhang">
						<view class="d-zuo-10 d-you-10 d-wenzi-12">感谢参与</view>
					</view>
				</view>
				<view v-else-if="zhuangtai.wendadaan && zhuangtai.wendadaan.leixing ==4" class="d-kuan d-zyouyou-juzhong d-shang-10">
					<view class="d-bian-1 d-yuanjiao-50 d-neikuang-5 d-buhuanhang">
						<view class="d-zuo-10 d-you-10 d-wenzi-12 d-wenzi-yanse-hongse">已经中标</view>
					</view>
				</view>
			</view>
		</view>
		<view class="d-waikuang-10" v-if="tiezineirong.daanshenhe != 1 || member.is_admin || uid==tiezineirong.uid">
			【答】<jyf-parser :html="tiezineirong.daan"   :use-cache="true"></jyf-parser>
		</view>
		<!--九格图片-->
		<!--帖子内容图片-->
		<view class="d-zuoyou-neikuang-10">
			<view class="d-fu-kuan-10" >
				<block v-for="(itemtu, indextu) in tiezineirong.jiugetu" :key="indextu">
					<view class="d-kuan-30 d-zuo d-liangbian-10">
						<image :src="itemtu.url" mode="aspectFill" @click="showimgs(indextu)" class="d-img-100-bai d-yuanjiao-6 d-yinying-10"></image>
					</view>
				</block>
				<view class="d-clear"></view>
			</view>
		</view>

	</view>
	<u-gap height="50" bgColor="#ffffff"></u-gap>
	<!--举报-->
	<u-row justify="space-between">
		<u-col span="6">
		</u-col>
		<u-col span="6">
			<view class="d-kuan">
				<view class="d-kuan-70" style="float: right;justify-content: flex-end;">
					<u-icon name="bell" color="#919191" label="举报" size="28" @click="jubaoopen()"></u-icon>
				</view>
			</view>
		</u-col>
	</u-row>
	
	
	
	<view v-if="wenda.wendakaiguan ==1">
		<u-tabbar
			:value="wendatijiao"
			@change="wendatijiaochange"
			:fixed="true"
			:placeholder="true"
			:safeAreaInsetBottom="true"
			activeColor="#ff9346"
		>
			<u-tabbar-item text="提交答案" icon="plus-circle"  @click="wendatijiaodata" ></u-tabbar-item>
		</u-tabbar>
	</view>
	<view class="d-kuan d-gao-100"></view>

<view>

	

	<view class="ditail-copyright" :style="'display:' + display">
		<block data-type="template" data-is="tempCopyright" data-attr="webSiteName:webSiteName,domain:domain">
			<view> {{webSiteName}} </view>
		</block>
	</view>

	<!-- 无法访问网络时 -->
	<view class="showerror" :style="'display:' + showerror">
		<!--image src="/static/images/cry80.png" style="height:100rpx;width:100rpx"></image-->
		<view class="errortext">{{errMessage}}</view>
	</view>

</view>
</view>
</view>
</template>

<script>

import config from "../../utils/config";


var Api = require("../../utils/api.js");
var util = require("../../utils/util.js");

var wxApi = require("../../utils/wxApi.js");
var wxRequest = require("../../utils/wxRequest.js");
const innerAudioContext = uni.createInnerAudioContext();
let isFocusing = false;
const pageCount = config.getPageCount;
var webSiteName = config.getWebsiteName;
var domain = config.getDomain;
var defaultskin = config.getskin;
let rewardedVideoAd = null;
var wss = config.getWss;

export default {
  data() {
    return {
      detail: {
        content: {
          rendered: ""
        },
        title: {},
        acf: {}
      },
      content: {
        rendered: ""
      },
      title: '',
      acf: {},
      defaultskin: defaultskin,
      skin: defaultskin,
      //title: '文章内容',
      webSiteName: webSiteName,
      html: " ",
      detailDate: '',
      display: 'none',
      showerror: 'none',
      page: 1,
      isLastPage: false,
      parentID: "0",
      scrollHeight: 0,
      xiangguan: [],
      link: '',
      dialog: {
        title: '',
        content: '',
        hidden: true
      },
      content: '',
      flag: 1,
	   tagStyle: {
	      img: "height:auto!important;display:block"
	    },
      enableComment: true,
      isLoading: false,
      total_comments: 0,
      userInfo: {},
      shareImagePath: '',
      fristOpen: false,
      domain: domain,
      platform: '',
      tagStyle: {},
      errMessage: "",
      commentCount: "",
      likeCount: "",
      postID: "",
      postImageUrl: "",
      commentsList: "",
      article_article: "",
	  tiezi: [],
	  tieziindex:{},
	  tiezineirong: {},
	  jiazai:true,
	  tiezijiazai:false,
	  pinglun: [],
	  pingluntongji: 0,
	  tieids: '',
	  "reqFlag": false ,// 请求标志，防止重复操作，true表示请求中
	  member:[],
	  userInfo: '',
	  memberuid: '',
	  dianzan:'',
	  shoucang:'',
	  pingluncontents:'',
	  tieneirong:'',
	  rzs:'',
	  v:config.getDomain+'/static/default/web/img/V.png',
	  tieziuid:'',
	  guanzhuuid:'',
	  uid:'',
	  tongji:{},
	  jubaoshuju:{},
	  jubaoxuanzedata:{},
	  qid:'',
	  scrollTop: 0,
	  bgColor: '#ffffff',
	  dianzanshu:'0',
	  dianzandata:{},
	  shehea:0,
	  shenheshow:false,
	  keycode:'',
	  unshenhe:'1',
	  wenda:{},
	  postsList:[],
	  wendakaiguan:'',
	  wendatijiao:0,
	  keycode:'',
	  zhaopin:{},
	  wendadata:{},
	  jubaoshow:'',
	  touxiang:{},
	  zhuangtai:[]
    };
  },

  components: {

  },
  props: {},
  onPageScroll(e) {
  	this.scrollTop = e.scrollTop;
	//console.log("scrollTop",e.scrollTop);
  },
  onShow: function (options) {
    var that = this;
    var skin = uni.getStorageSync('skin');

    if (skin != '') {
      that.setData({
        skin: skin
      });
    }
	
  },
  onLoad: function (options) {
	  
    var duixin = this;
	duixin.tieids = options.id;

	
	//duixin.gundong();
    var skin = uni.getStorageSync('skin');
	//判断用户是否登录
	var userInfo = uni.getStorageSync('userInfo');
	var keycode = uni.getStorageSync('keycode');
	duixin.keycode = keycode;
	//console.log("options",options);
	duixin.getDananzhuangtaidata(options.id);
	if (keycode) {
		var member = uni.getStorageSync('member');
		var memberuid = uni.getStorageSync('memberuid');
		duixin.member = member;
		duixin.userInfo = userInfo;
		duixin.memberuid = memberuid;
		duixin.uid = memberuid;
		duixin.getimin(memberuid,member);
	}
	duixin.getDaandata(options.id);

	//duixin.getTieziid(options.qid,options.id,memberuid,userInfo);


	//console.log('duixin.tieziindex000: ',duixin.tieziindex);
    if (skin != '') {
      duixin.setData({
        skin: skin
      });
    }
	
	
  },
  onShow: function () {
  	  //判断用户是否登录
  	  var userInfo = uni.getStorageSync('userInfo');
  	  var member = uni.getStorageSync('member');
  	  if (userInfo) {
  		  this.getTongjis(this.uid);
  		  this.getimin(this.uid,member);
  	  }
  },
  onUnload: function () {},
  //分享到个人朋友圈
  onShareAppMessage: function (res) {
    return {
      title: this.tiezineirong.title,
      path: 'pages/tiezi/daantiezi?id=' + this.tiezineirong.index.id + '&qid=' + this.tiezineirong.index.cid,
      //imageUrl: this.tiezineirong.post_full_image,
      success: function (res) {
        // 转发成功
        //console.log(res);
      },
      fail: function (res) {
        //console.log(res); // 转发失败
      }
    };
  },
  //分享到朋友圈
  onShareTimeline: function (res) {
  	  return {
  	    title: this.tiezineirong.title,
  	    path: 'pages/tiezi/daantiezi?id=' + this.tiezineirong.index.id + '&qid=' + this.tiezineirong.index.cid,
		imageUrl: this.tiezineirong.title,
  	    success: function (res) {// 转发成功
  	    },
  	    fail: function (res) {// 转发失败
  	    }
  	  };
  },
  methods: {
    BackPage() {
      uni.navigateBack({
        delta: 1
      });
    },
	fanhui() {
		const pages = getCurrentPages();  //判断跳转了多少页
		if (pages.length === 2) {  
			uni.navigateBack({
				delta: 1
			});
		} else if (pages.length === 1) { //如果没有上一页返回首页
			uni.switchTab({
				url: '/pages/index/index',
			})
		} else {
			uni.navigateBack({
				delta: 1
			});
		}
		
	},

    toHome() {
      uni.reLaunch({
        url: '/pages/index/index'
      });
    },

    gotowebpage: function () {
      var self = this;
      var url = '../webpage/webpage';
      uni.navigateTo({
        url: url + '?url=' + self.link
      });
    },
    copyLink: function (url) {
      uni.setClipboardData({
        data: url,
        success: function (res) {
          uni.getClipboardData({
            success: function (res) {
              uni.showToast({
                title: '链接已复制',
                image: "/static/images/uploads/link.png",
                duration: 2000
              });
            }
          });
        }
      });
    },
    copyText: function (e) {
      console.log(e);
      uni.setClipboardData({
        data: e.currentTarget.dataset.text,
        success: function (res) {
          uni.getClipboardData({
            success: function (res) {
              uni.showToast({
                title: '复制成功'
              });
            }
          });
        }
      });
    },
    gourl: function () {
      var url = '../webpage/webpage';
      uni.navigateTo({
        url: url + '?url=' + e.currentTarget.dataset.text
      });
    },
    goHome: function () {
      uni.switchTab({
        url: '../index/index'
      });
    },
    //获取是否开启评论设置
    getEnableComment: function (id) {
      var self = this;
      var getEnableCommentRequest = wxRequest.getRequest(Api.getEnableComment());
      getEnableCommentRequest.then(response => {
        if (response.data.enableComment != null && response.data.enableComment != '') {
          if (response.data.enableComment === "1") {
            self.setData({
              enableComment: true
            });
          } else {
            self.setData({
              enableComment: false
            });
          }
        }

        ;
      });
    },

    //拖动进度条事件
    //给a标签添加跳转和复制链接事件
    wxParseTagATap: function (e) {
      var self = this;
      var href = e.currentTarget.dataset.src;
      //console.log(href);
      var domain = config.getDomain; //可以在这里进行一些路由处理

      if (href.indexOf(domain) == -1) {
        uni.setClipboardData({
          data: href,
          success: function (res) {
            uni.getClipboardData({
              success: function (res) {
                uni.showToast({
                  title: '链接已复制',
                  //icon: 'success',
                  image: "/static/images/uploads/link.png",
                  duration: 2000
                });
              }
            });
          }
        });
      } else {
        var slug = util.GetUrlFileName(href, domain);

        if (slug == 'index') {
          uni.switchTab({
            url: '../index/index'
          });
        } else {
          var getPostSlugRequest = wxRequest.getRequest(Api.getPostBySlug(slug));
        }
      }
    },
	//个人关注判断
	getGerenGuanzhus(touid) {
		var duixin = this;
		//console.log('touid: ',touid);
		//var touid = duixin.tieziindex['uid'];
		var getGerenGuanzhuRequest = wxRequest.getRequest(Api.getGerenGuanzhu(duixin.memberuid,duixin.userInfo,touid));
		var res;
		getGerenGuanzhuRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.data.guanzhuuid == 1) {
					duixin.guanzhuuid = res.data.data.guanzhuuid;
				} else {
					duixin.guanzhuuid = 0
				}
				
			}
		})
		
	},
	//关注
	getGuanzhus(index,uid) {
		var duixin = this;
		var getGuanzhuRequest = wxRequest.getRequest(Api.getGuanzhu(duixin.memberuid,duixin.userInfo)+'&uid='+uid);
		var res;
		getGuanzhuRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.data.status == 1) {
					duixin.guanzhuuid = 1;
					
					uni.showToast({
						title: res.data.msg,
						icon: 'success',
						duration: 2000
					});
					
				} else {
					duixin.guanzhuuid = 0;
					
					uni.showToast({
					  title: res.data.msg,
					  mask: false,
					  duration: 1000
					});
				}
				
			} else {
				uni.showToast({
					icon: 'none',
					title: res.data.msg+'关注提示'
				});
			}
		})
	},
    //获取评论
    fetchCommentData: function () {
      
    },
	// 登录校验
	checkLogin() {
		// TODO 此处填写登录校验逻辑
		var userInfo = uni.getStorageSync('userInfo');
		if (userInfo) {
			return true;
		} else {
			uni.showModal({
				title: '提示',
				content: '请先登录',
				confirmText: '前往登录',
				success: function(res) {
					if (res.confirm) {
						uni.redirectTo({
							url: '/pages/login/login'
						});
					}
				}
			});
			return false;
		}
	},
	// 输入框聚焦
	focusOn() {
		this.checkLogin();
	},
	// 新增评论
	add(req,uid,code) {
		
		if (!this.checkLogin()) {
			return
		}
		var that = this;
		//that.fetchDetailData(options.id);
		var skin = uni.getStorageSync('skin');
		var tieids = that.tieids;
		//console.log("帖子ids",tieids);
		//判断用户是否登录
		var userInfo = uni.getStorageSync('userInfo');
		//console.log("options",options);
		if (userInfo) {
			var member = uni.getStorageSync('member');
			var memberuid = uni.getStorageSync('memberuid');
			
		}
		if (that.reqFlag) {
			uni.showToast({
				title: '操作频繁',
				duration: 500
			});
			return
		}
		
		that.reqFlag = true;
		let params = {
			"articleId": that.articleId,
			"pId": req.pId,
			"content": req.content
		}
		
		var datas = "is_ajax=1&content="+that.pingluncontents;
		console.log("req.rid",req);
		var postPinglunRequest = wxRequest.postRequest(Api.postPinglun(req.pId,memberuid,userInfo,req.rid),datas);
		postPinglunRequest.then(response => {
			if (response.data.code == 1) {
			  //console.log('二级评论',req.erjiuid); 
			  uni.showToast({
			  	title: "评论成功",
			  	duration: 1000
			  });
			  that.reqFlag = false;
			  that.$refs.hbComment.addComplete();
			  that.getPinglunNeirong(tieids,memberuid,userInfo);
			  uni.showToast({
			  	title: "更新加载",
			  	duration: 2000
			  });
			  if(req.rid >0){
				  var pinglun_data = '{"type":"pinglun","tieid":"'+tieids+'","uid":"'+that.uid+'","tieuid":"'+that.tieziindex.uid+'","tiename":"2","tozanuid":"'+req.erjiuid+'","tozanname":"'+that.member.name+'","avatar":"'+that.member.avatar+'"}';
				  if(req.erjiuid != that.uid) {
				  	
					/*#ifdef H5*/
					that.duixinim.send(pinglun_data);
					/*#endif*/
					/*#ifdef MP-WEIXIN || APP-PLUS*/
					uni.sendSocketMessage({
					      data: pinglun_data
					});
					/*#endif*/
				  }
			  } else {
				  var pinglun_data = '{"type":"pinglun","tieid":"'+tieids+'","uid":"'+that.uid+'","tieuid":"'+that.tieziindex.uid+'","tiename":"2","tozanuid":"'+that.uid+'","tozanname":"'+that.member.name+'","avatar":"'+that.member.avatar+'"}';
				  if(that.tieziindex.uid != that.uid) {
				  	
					/*#ifdef H5*/
					that.duixinim.send(pinglun_data);
					/*#endif*/
					/*#ifdef MP-WEIXIN || APP-PLUS*/
					uni.sendSocketMessage({
					      data: pinglun_data
					});
					/*#endif*/
				  }
			  }
			  
			} else {
			  uni.showToast({
			  	title: response.data.msg,
			  	duration: 1000
			  });
			}
		});
		// TODO 接入真实接口
		// let params = {
		// 	"articleId": this.articleId,
		// 	"pId": req.pId,
		// 	"content": req.content
		// }
		// this.$u.api.commentAdd(params).then(res => {
		// 	uni.showToast({
		// 		title: '操作成功！',
		// 		duration: 3000
		// 	});
		// 	this.$refs.hbComment.addComplete();
		// 	this.getComment();
		// 	this.reqFlag = false;
		// }).catch(res => {
		// 	this.reqFlag = false;
		// })
		// 下边假装请求成功
		//this.reqFlag = false;
		//this.$refs.hbComment.addComplete();
		//this.getComment();
	},

	
	//用户认证
	getRenzheng(uid){
		var duixin = this;
		var getRenzhengszhiRequest = wxRequest.getRequest(Api.getRenzhengs(uid));
	    var res;
		getRenzhengszhiRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.code == 1){
					duixin.rzs = res.data.data.rzs[0];
					//console.log('认证：',duixin.rzs);
				} else {
					
				}
			} else {
			  /*uni.showToast({
			  	icon: 'none',
			  	title: '获取失败，请稍后重试'
			  });*/
			  that.shoucang = "heart";
			}
		})
	},
	// 评论内容
	pingluncontent(e){
		var duixin = this;
		duixin.pingluncontents = e;
		//console.log('pinglun',e)
	},
	//获取当前页面
	getDangqianurl() {
		//获取当前页面栈的实例
		let pages = getCurrentPages();
		//获取当前页面
		let currentPage = pages[pages.length-1].$page.fullPath;
		let url = currentPage;
		uni.setStorageSync('dangqianUrl', url);
	},
	// 个人页面
	getgeren(uid) {
		
		var url = '../u/index?&uid='+uid;
		uni.navigateTo({
			url: url
		});
	},
	//阅读图片
	showimgs(e){
		var duixin = this;
		var urls = duixin.tiezineirong.jiugetu;
		var urlsimg = [];
		for (let i = 0; i < urls.length; i++) {
			urlsimg[i] = urls[i].url
		}
		uni.previewImage({
		  urls: urlsimg,
		  current: e
		});
	},
	yunurl(url,ma) {
		//console.log("附件url",url);
		uni.setClipboardData({
		  data: url+' 认证码:'+ma,
		  success: () => {
		    uni.showToast({
		      title: '复制成功'
		    });
		  },
		  fail: () => {
		    uni.showToast({
		      title: '复制失败.未开通权限',
		      icon: 'none'
		    });
		  }
		});
	},
	jubao(id) {
		console.log("id",id);
	},
	jubaoclose(){
		this.jubaoshow = false
	},
	jubaoopen(){
		var duixin = this;
		duixin.jubaoshow = true
		//console.log("id");
	},
	postJubao(id){
		console.log("postJubao",id);
	},
	checkboxChange(n) {
		this.jubaoxuanzedata = n;
	},
	//重新链接
	getimin(uid,member){
		var duixin = this;
		
		if (!duixin.duixinimin || duixin.duixinimin.readyState == 3) { 
			/*#ifdef H5*/
			duixin.duixinimin = new WebSocket(wss);  
			  
			duixin.duixinimin.onopen = () => {  
			  console.log('im连接成功',duixin.duixinim);  
			  duixin.message = '已连接';
			  var login_data = '{"type":"login","name":"'+member.name+'","uid":"'+uid+'"}';
			  console.log("登录成功，发送登录数据:"+login_data);
			  duixin.duixinim.send(login_data);
			};  
			  
			duixin.duixinimin.onmessage = duixin.getOnmessage;  
			  
			duixin.duixinimin.onclose = function(event) {
			  console.log('im已关闭，尝试重新连接...', event);
			  duixin.message = '连接已断开';  
			  setTimeout(() => {  
				duixin.getimin(); // 延迟重新连接，避免频繁尝试连接
				console.log('im连接成功in'); 
			  }); // 5秒后重新连接  , 5000
			};  
			duixin.duixinimin.onerror = function(error) {  
			  console.error('im错误:', error);  
			}; 
			/*#endif*/
			/*#ifdef MP-WEIXIN  || APP-PLUS*/
			uni.connectSocket({
			  url: wss,
			  success(data) {
			     console.log("websocket连接成功",data);
			  },
			  fail(err) {
				console.error('WebSocket连接失败', err);
			  }
			});
			uni.onSocketOpen(function (res) {
			  console.log('WebSocket连接已打开！');
			  var login_data = '{"type":"login","name":"'+member.name+'","uid":"'+uid+'"}';
			    uni.sendSocketMessage({
			        data: login_data
			    });
			});
			uni.onSocketMessage(function (res) {
			  console.log('收到服务器内容：' + res.data);
			  duixin.getOnmessage(res);
			});
			uni.onSocketClose(function (res) {
			  console.log('WebSocket 已关闭！');
			  setTimeout(() => {
				duixin.getimin(); // 延迟重新连接，避免频繁尝试连接
				console.log('im连接成功in'); 
			  }); // 5秒后重新连接  , 5000
			});
			uni.onSocketError(function (res) {
			  console.log('WebSocket连接打开失败，请检查！');
			});
			/*#endif*/
		} else {  
		console.log('im连接已存在');  
		} 
	},
	getOnmessage(e){
		var duixin = this;
		//console.log('收信息',e.data);
		var shouxin = JSON.parse(e.data); 
		duixin.shouxin = shouxin;
		if(shouxin.type == 'zan') {
			if(duixin.uid==shouxin.tieuid){
				duixin.toptishishow = true;
				duixin.dianzanname = shouxin.tozanname;
				duixin.dianzantouxiang = shouxin.avatar;
				duixin.duanxintongzhi = 1;
				duixin.getTongjis(duixin.uid);
				setTimeout(() => {  
					duixin.toptishishow = false; // 五秒后隐藏
				}, 3000); // 延迟时间为 5000 毫秒（即 5 秒）
			}
			
		}
	},
	//获取消息统计
	getTongjis(uid) {
	  	var self = this;
	  	//console.log('xx'); 
	  	var getXiaoxitongjiRequest = wxRequest.getRequest(Api.getXiaoxitongji(uid));
	  	getXiaoxitongjiRequest.then(response => {
	  		if (response.data.code == 1) {
	  		  //console.log(response.data.data); 
	  		  self.tongji = response.data.data
			  self.tongzhis(response.data.data);
	  		} else {
	  		  self.setData({
	  			displaySwiper: "none"
	  		  });
	  		}
	  	});
	},
	// 通知
	tongzhis(e){
		var tongjishu = e;
		
	},
	
	
	//圈子
	getQuan(id){
		var url = '../quan/quanzi?id=' + id;
		uni.navigateTo({
				url: url
		});
	},
	//审核帖子
	shenhe(e) {
		
		if(e ==1){
			this.shenheshow = true;
		}
	},
	//审核关闭
	shenheguanbi(){
		this.shenheshow = false;
	},
	
	//点赞评论
	like(){
		
	},
	//删除评论
	del(){
		
	},
	//问答进度条
	getWendadata(id) {
		var duixin = this;
		var getWendaRequest = wxRequest.getRequest(Api.getWenda(id));
		var res;
		getWendaRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.code == 1){
					duixin.wenda = res.data.data;
					duixin.wendakaiguan = res.data.data['wendakaiguan'];
					//console.log(res.data.data['wendakaiguan'])
				} else {
					
				}
			} else {
	
			}
		})
	},
	
	//答案内容
	getDaandata(tieid){
        var duixin = this;
		
		var getWendadaanRequest = wxRequest.getRequest(Api.getWendadaan(tieid,duixin.uid,duixin.keycode));
		var res;
		getWendadaanRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.code == 1){
					duixin.tiezineirong = res.data.data;
					duixin.jiazai = false;
					duixin.tiezijiazai = true;
					duixin.getTouxiangdeda(res.data.data.uid,res.data.data.inputip);
				} else {
					
				}
			} else {
			
			}
		})
	},
	//头像
	getTouxiangdeda(uid,ip){
		var duixin = this;
		var getWendadaanRequest = wxRequest.getRequest(Api.getTouxiang(uid,ip));
		var res;
		getWendadaanRequest.then(response => {
			res = response;
			if(res.data.code) {
				if(res.data.code == 1){
					duixin.touxiang = res.data.data;
					
				} else {
					
				}
			} else {
			
			}
		})
	},
	//问答奖励
	getWendajianglidata(leixing,tieid,tieuid){
		var duixin = this;
		if(leixing==1){
			var zhuangtai = "确认选择鼓励1积分";
		} else if(leixing==2){
			var zhuangtai = "确认选择鼓励0.1";
		} else if(leixing==3){
			var zhuangtai = "确认选择感谢参与";
		} else if(leixing==4){
			var zhuangtai = "确认选择中标";
		}
		uni.showModal({
			title: zhuangtai,
			//content: '请先登录',
			confirmText: '确认',
			success: function(res) {
				if (res.confirm) {
					//console.log("请先登录",4)
					duixin.getWendajiangligaibian(leixing,tieid,tieuid);
				}
			}
		});
	},
	getWendajiangligaibian(leixing,tieid,tieuid){
		var duixin = this;
		var getWendajiangliRequest = wxRequest.getRequest(Api.getWendajiangli(duixin.uid,duixin.keycode,tieid,leixing,tieuid));
		var res;
		getWendajiangliRequest.then(response => {
			res = response;
			if(res.data.code) {
				    console.log('4',res.data.msg.status);
					if(res.data.msg.status==4){
						duixin.getdaanqueren(4,tieid); 
					} else if(res.data.msg.status==1) {
						duixin.getdaanqueren(1,tieid);
					} else if(res.data.msg.status==2) {
						duixin.getdaanqueren(2,tieid);
					} else if(res.data.msg.status==3) {
						duixin.getdaanqueren(3,tieid);
					}
			} else {
			}
		})
	},
	//答案确认
	getdaanqueren(id,tieid){
		var duixin = this;
		if(id==1){
			var zhuangtai = "鼓励积分";
		} else if(id==2){
			var zhuangtai = "鼓励0.1";
		} else if(id==3){
			var zhuangtai = "感谢参与";
		} else if(id==4){
			var zhuangtai = "中标成功";
		}
		duixin.getDananzhuangtaidata();
		uni.showToast({
		  title: zhuangtai,
		  duration: 1000
		});
	},
	getdaan(){
		console.log(e)
		/*var url = '../u/index?&uid='+uid;
		uni.navigateTo({
			url: url
		});*/
	},
	//确认审核
	qurrenshenhe(){
		var duixin = this;
		uni.showModal({
			title: '确定审核',
			//content: '请先登录',
			confirmText: '确认',
			success: function(res) {
				if (res.confirm) {
					duixin.postDananshenhedata();
					duixin.getDaandata(duixin.tieids);
				}
			}
		});
	},
	//审核答案
	postDananshenhedata(){

		var duixin = this;
		var postDananshenheRequest = wxRequest.getRequest(Api.postDananshenhe(duixin.uid,duixin.keycode,duixin.tiezineirong.id,duixin.tiezineirong.tid,duixin.tiezineirong.uid));
		var res;
		postDananshenheRequest.then(response => {
			res = response;
			if(res.data.code) {
				duixin.tiezineirong.daanshenhe = 1;
				uni.showToast({
				  title: "审核成功",
				  duration: 1000
				});
			} else {
			}
		})
	},
	//答案帖子状态
	getDananzhuangtaidata(){
		var duixin = this;
		var getDananzhuangtaiRequest = wxRequest.getRequest(Api.getDananzhuangtai(duixin.tieids));
		var res;
		getDananzhuangtaiRequest.then(response => {
			res = response;
			if(res.data.code) {
				duixin.zhuangtai = res.data.data;
			} else {
			}
		})
	},
	//3,tieids,item.uid
	//问答奖励
	getWendajianglidata(leixing,tieid,tieuid){
		var duixin = this;
		if(leixing==1){
			var zhuangtai = "确认选择鼓励1积分";
		} else if(leixing==2){
			var zhuangtai = "确认选择鼓励0.1";
		} else if(leixing==3){
			var zhuangtai = "确认选择感谢参与";
		} else if(leixing==4){
			var zhuangtai = "确认选择中标";
		}
		uni.showModal({
			title: zhuangtai,
			//content: '请先登录',
			confirmText: '确认',
			success: function(res) {
				if (res.confirm) {
					//console.log("请先登录",4)
					duixin.getWendajiangligaibian(leixing,tieid,tieuid);
				}
			}
		});
	},
	getWendajiangligaibian(leixing,tieid,tieuid){
		var duixin = this;
		var getWendajiangliRequest = wxRequest.getRequest(Api.getWendajiangli(duixin.uid,duixin.keycode,tieid,leixing,tieuid));
		var res;
		getWendajiangliRequest.then(response => {
			res = response;
			if(res.data.code) {
				    console.log('4',res.data.msg.status);
					if(res.data.msg.status==4){
						duixin.getdaanqueren(4,tieid); 
					} else if(res.data.msg.status==1) {
						duixin.getdaanqueren(1,tieid);
					} else if(res.data.msg.status==2) {
						duixin.getdaanqueren(2,tieid);
					} else if(res.data.msg.status==3) {
						duixin.getdaanqueren(3,tieid);
					}
			} else {
			}
		})
	}
	
  }
};
</script>
<style>
@import "./tiezi.css";
/* #ifdef H5 */
::v-deep img {
    max-width: 100%;
	border-radius: 10px;
}
::v-deep p {
	    display: block;
	    margin-top: 5px;
		margin-bottom:5px;
		line-height:30px !important;
		font-size: 18px;
} 
::v-deep pre {
	padding: 10px;
	background-color: #262626;
	border-radius: 10px;
	color: #eaeaea;
}
/* #endif */

</style>